Fix compiler warnings in the release build
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 29 Jan 2020 11:00:48 +0000 (12:00 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Tue, 11 Feb 2020 13:39:52 +0000 (13:39 +0000)
We have a bunch of debug-only variables that get set and never used
outside of debug code paths, and the compiler is not happy about it.

gdk/gdkgl.c
gdk/gdkglcontext.c

index b1073483a7cf5efcfc53fff22eca98dcbf4638cf..1e24e776873df3fec386f43a6e137fcea9fab677 100644 (file)
@@ -443,7 +443,6 @@ gdk_gl_texture_from_surface (cairo_surface_t *cairo_surface,
                             cairo_region_t  *region)
 {
   GdkGLContext *paint_context;
-  GdkDisplay *display;
   cairo_surface_t *image;
   double device_x_offset, device_y_offset;
   cairo_rectangle_int_t rect, e;
@@ -458,13 +457,18 @@ gdk_gl_texture_from_surface (cairo_surface_t *cairo_surface,
   guint target;
 
   paint_context = gdk_gl_context_get_current ();
-  if (paint_context)
-    display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (paint_context));
-  else
-    display = NULL;
 
-  if (paint_context &&
-      GDK_DISPLAY_DEBUG_CHECK (display, GL_SOFTWARE) == 0 &&
+#ifdef G_ENABLE_DEBUG
+  if (paint_context != NULL)
+    {
+      GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (paint_context));
+
+      if (GDK_DISPLAY_DEBUG_CHECK (display, GL_SOFTWARE) == 0)
+        return;
+    }
+#endif
+
+  if (paint_context != NULL &&
       GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
       GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, cairo_surface, region))
     return;
index 20f4727b4811104966c7fefa7b2c5886ec42da11..4a01b2bab99050ab2c32c9deee163d7889b7df49 100644 (file)
@@ -638,7 +638,11 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
                                      int           minor)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+  gboolean force_gles = FALSE;
   int version, min_ver;
+#ifdef G_ENABLE_DEBUG
+  GdkDisplay *display;
+#endif
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
   g_return_if_fail (!priv->realized);
@@ -651,10 +655,16 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
       return;
     }
 
-  /* Enforce a minimum context version number of 3.2 */
   version = (major * 100) + minor;
 
-  if (priv->use_es > 0 || GDK_DISPLAY_DEBUG_CHECK (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), GL_GLES))
+#ifdef G_ENABLE_DEBUG
+  display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
+  force_gles = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES);
+#endif
+  /* Enforce a minimum context version number of 3.2 for desktop GL,
+   * and 2.0 for GLES
+   */
+  if (priv->use_es > 0 || force_gles)
     min_ver = 200;
   else
     min_ver = 302;
@@ -683,12 +693,25 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
                                      int          *minor)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
+  gboolean force_gles = FALSE;
+#ifdef G_ENABLE_DEBUG
+  GdkDisplay *display;
+#endif
   int default_major, default_minor;
   int maj, min;
 
   g_return_if_fail (GDK_IS_GL_CONTEXT (context));
 
-  if (priv->use_es > 0 || GDK_DISPLAY_DEBUG_CHECK (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), GL_GLES))
+#ifdef G_ENABLE_DEBUG
+  display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
+  force_gles = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES);
+#endif
+
+  /* Default fallback values for uninitialised contexts; we
+   * enforce a context version number of 3.2 for desktop GL,
+   * and 2.0 for GLES
+   */
+  if (priv->use_es > 0 || force_gles)
     {
       default_major = 2;
       default_minor = 0;
@@ -936,6 +959,10 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
   gboolean has_npot, has_texture_rectangle;
+  gboolean gl_debug = FALSE;
+#ifdef G_ENABLE_DEBUG
+  GdkDisplay *display;
+#endif
 
   if (!priv->realized)
     return;
@@ -993,7 +1020,12 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
         priv->is_legacy = TRUE;
     }
 
-  if (priv->has_khr_debug && GDK_DISPLAY_DEBUG_CHECK (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), GL_DEBUG))
+#ifdef G_ENABLE_DEBUG
+  display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
+  gl_debug = GDK_DISPLAY_DEBUG_CHECK (display, GL_DEBUG);
+#endif
+
+  if (priv->has_khr_debug && gl_debug)
     {
       priv->use_khr_debug = TRUE;
       glGetIntegerv (GL_MAX_LABEL_LENGTH, &priv->max_debug_label_length);